<?php
/* Class BadgeClass
 * Documentation can be found at:
* https://github.com/mozilla/openbadges/wiki/Assertions#badgeclass */

class BadgeClass {
	
	/* Mandatory fields */
	private $name;
	private $description;
	private $image;
	private $criteria;
	private $issuer;
	
	/* Optional fields */
	private $alignment;
	private $tags;
	
	/* Getters & Setters */
	public function getName() {
		return $this->name;
	}
	
	public function setName($name) {
		$this->name = $name;
	}
	
	public function getDescription() {
		return $this->description;
	}
	
	public function setDescription($description) {
		$this->description = $description;
	}
	
	public function getImage() {
		return $this->image;
	}
	
	public function setImage($image) {
		$this->image = $image;
	}
	
	public function getCriteria() {
		return $this->criteria;
	}
	
	public function setCriteria($criteria) {
		$this->criteria = $criteria;
	}
	
	public function getIssuer() {
		return $this->issuer;
	}
	
	public function setIssuer($issuer) {
		$this->issuer = $issuer;
	}
	
	public function getAlignment() {
		return $this->alignment;
	}
	
	public function setAlignment($assertion) {
		$this->alignment = $alignment;
	}
	
	public function getTags() {
		return $this->tags;
	}
	
	public function setTags($tags) {
		$this->tags = $tags;
	}
	
	public function checkValidity() {
		return isset($this->name) && isset($this->description) && isset($this->image) &&
		isset($this->criteria) && isset($this->issuer);
	}
	
	public function getArray() {
		
		if (!$this->checkValidity())
			return null;
		
		$array["name"] = $this->name;
		$array["description"] = $this->description;
		$array["image"] = $this->image;
		$array["criteria"] = $this->criteria;
		$array["issuer"] = $this->issuer;
	
		if (isset($this->alignment))
			$array["alignment"] = $this->alignment;
	
		if (isset($this->evidence))
			$array["tags"] = $this->tags;
	
		return $array;
	}
}
?>